package 备战春招12月27日开始刷题.牛客网的题目;
import java.util.*;
// https://www.nowcoder.com/practice/35b8166c135448c5a5ba2cff8d430c32?tpId=188&&tqId=38659&rp=1&ru=/activity/oj&qru=/ta/job-code-high-week/question-ranking
public class simpleNC56回文数字1229 {
        /**
         *
         * @param x int整型
         * @return bool布尔型
         */
        /*
         * 最优解法有木有
         */

        public boolean isPalindrome(int x) {
            // 如果是负数，或者10的整数倍，返回false
            if (x < 0 || x != 0 && x % 10 == 0)
                return false;
            int reverse = 0;
            while (x > reverse) {
                reverse = reverse * 10 + x % 10;
                x = x / 10;
            }
            return (reverse == x || reverse / 10 == x);
        }

    public static void main(String[] args) {
        System.out.println(new simpleNC56回文数字1229().isPalindrome(121));
        System.out.println(new simpleNC56回文数字1229().isPalindrome(-1));
    }
}
